#!/bin/tcsh -f

if ($#argv != 1) then
   echo "Usage: $0 viewname"
   echo "copies all VOB source files to archive"
   goto error
endif

setenv CLEARTOOL_DIR `which cleartool`
if ( ! ($?CLEARTOOL_DIR) ) then
   echo "Not found cleartool "
   goto error
endif

setenv CLEARTOOL_VIEW `(cleartool pwv | grep -v NONE)`
if ( ! ($?CLEARTOOL_VIEW) ) then
   echo "Not found cleartool view"
   goto error
endif

setenv iview "$argv[1]"
find /vobs -type f -name "*.c" -o -name "*README" -o -name "*.sh" -o -name "*.cc" -o -name "*.mkf" -o -name "*.cxx" -o -name "*.h" -o -name "*.hh" -o -name "*.hxx" -o -name "*.ttcn" -o -name "*makefile" -o -name "*.def" -o -name "Makefile" -o -name "*.lc" -o -name "*.cfg" -o -name "*.mk" -o -name "*.txt" -o -name "*.sig" -o -name "*.prj" -o -name "*.dox"  | cpio -dumpv .

echo "Zipping..."
tar cvf -  ./*.cs ./vobs | gzip > $iview.tar.gz

\rm -rf ./*.cs ./vobs

done:
   echo "Done!"
   exit 0
error:
   echo "Failed!!!"
   exit 1
